#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;


class Solution
{
public:
    // https://gitee.com/link?target=https%3A%2F%2Fleetcode.cn%2Fproblems%2Ffind-pivot-index%2F
    int pivotIndex(vector<int> &nums)
    {
        int n = nums.size();
        vector<int> v1(n), v2(n);
        for (int left = 1, right = nums.size() - 2; left < nums.size(); left++, right--)
        {
            v1[left] = v1[left - 1] + nums[left - 1];
            v2[right] = v2[right + 1] + nums[right + 1];
        }
        for (int i = 0; i < nums.size(); i++) // 数组中有n个元素v1[0]保存的是nums[0]之前所有元素的和不包括nums[0]，
        {                                     // 而v2[0]保存的是nums[0]之后所有元素的和不包括nums[0]；以此类推
            if (v1[i] == v2[i])
                return i;
        }
        return -1;
    }

    int pivotIndex1(int *nums, int numsSize)
    {
        int total = 0;
        for (int i = 0; i < numsSize; ++i)
        {
            total += nums[i];
        }
        int sum = 0;
        for (int i = 0; i < numsSize; ++i)
        {
            if (2 * sum + nums[i] == total)//此法更节省空间，用下标i左侧元素之和*2再加上i处元素等于数组元素总和找出中心位置
            {
                return i;
            }
            sum += nums[i];
        }
        return -1;
    }

    //https://gitee.com/link?target=https%3A%2F%2Fleetcode.cn%2Fproblems%2Fproduct-of-array-except-self%2F
    vector<int> productExceptSelf(vector<int>& nums) 
    {
        vector<int> v1(nums.size(), 1);
        vector<int> v2(nums.size(), 1);
        vector<int> v(nums.size());
        for(int left = 1, right = nums.size() - 2; left < nums.size(); left++, right--)
        {
            v1[left] = nums[left - 1] * v1[left - 1];
            v2[right] = nums[right + 1]*v2[right + 1];
        }
        for(int i = 0; i < nums.size(); i++)
        {
            v[i] = v1[i] * v2[i];
        }
        return v;
    }

    //https://gitee.com/link?target=https%3A%2F%2Fleetcode.cn%2Fproblems%2Fsubarray-sum-equals-k%2F
    int subarraySum(vector<int>& nums, int k) 
    {
        unordered_map<int, int> mp;
        int sum = 0;
        int count = 0;
        for(auto& c: nums)
        {
            sum += c;
            if(sum == k) count++;//这里不便让mp[0]++，
                                //避免之后有sum的值为0重复计数(k==0时会统计错误)
            if(mp.count(sum - k)) count += mp[sum-k];
            mp[sum]++;//这里需注意在判断在c之前和为sum-k的计数之后在++，避免sum-k等于sum的情况
        }
        return count;
    }
};


//https://gitee.com/link?target=https%3A%2F%2Fwww.nowcoder.com%2Fpractice%2F99eb8040d116414ea3296467ce81cbbc%3FtpId%3D230%26tqId%3D2023819%26ru%3D%2Fexam%2Foj%26qru%3D%2Fta%2Fdynamic-programming%2Fquestion-ranking%26sourceUrl%3D%252Fexam%252Foj%253Fpage%253D1%2526tab%253D%2525E7%2525AE%252597%2525E6%2525B3%252595%2525E7%2525AF%252587%2526topicId%253D196
int main() 
{
    int n,m,q;
    cin>>n>>m>>q;
    vector<vector<int>> vv1(n,vector<int>(m));
    vector<vector<long long>> vv2(n + 1, vector<long long>(m + 1));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin>>vv1[i][j];
        }
    }
    for(int i = 1; i < n  + 1; i++)
    {
        for(int j = 1; j < m + 1; j++)
        {
            vv2[i][j] = vv2[i - 1][j] + vv2[i][j - 1] - vv2[i - 1][j - 1] + vv1[i - 1][j - 1];
        }
    }

    int x1, y1, x2, y2;
    for(int i = 0; i < q; i++)
    {
        cin>>x1>>y1>>x2>>y2;
        cout<<vv2[x2][y2] - vv2[x1 - 1][y2] - vv2[x2][y1 - 1] + vv2[x1 - 1][y1 - 1] << endl;
    }
    return 0;
}